home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / CONTROL.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  123 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Definition of class TControl.  This defines the basic behavior of all
  8. // controls.
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_CONTROL_H)
  11. #define OWL_CONTROL_H
  12.  
  13. #if !defined(OWL_WINDOW_H)
  14. # include <owl/window.h>
  15. #endif
  16.  
  17. #if defined(BI_NAMESPACE)
  18. namespace OWL {
  19. #endif
  20.  
  21. // Generic definitions/compiler options (eg. alignment) preceeding the 
  22. // definition of classes
  23. #include <services/preclass.h>
  24.  
  25. //
  26. // enum TUseNative
  27. // ~~~~ ~~~~~~~~~~
  28. // Settings to suggest how a control should obtain its implementation, OWL or
  29. // Native. nuNever..nuAlways. Control can be later queried back per
  30. // instance to determine the choice made by looking at the nuUsing bit.
  31. //
  32. enum TNativeUse {
  33.               // Suggested native control use for class
  34.   nuNever,    // Instance should never use native implementation
  35.   nuAvoid,    // Avoid if possible, unless options require native
  36.   nuDontCare, // Don't care--control uses whatever is best
  37.   nuAttempt,  // Attempt to use, unless options not supported
  38.   nuAlways,   // Always use when available
  39.   nuSuggestion = 0xFF,
  40.  
  41.   nuUsing = 0x8000, // Instance is using native
  42. };
  43.  
  44. //
  45. // class TControl
  46. // ~~~~~ ~~~~~~~~
  47. class _OWLCLASS TControl : virtual public TWindow {
  48.   public:
  49.     TControl(TWindow*        parent,
  50.              int             id,
  51.              const char far* title,
  52.              int x, int y, int w, int h,
  53.              TModule*        module = 0);
  54.  
  55.     TControl(TWindow* parent, int resourceId, TModule* module = 0);
  56.    ~TControl();
  57.  
  58.     TNativeUse GetNativeUse() const;
  59.  
  60.   protected:
  61.  
  62.     // Constructor to alias non-OWL control
  63.     //
  64.     TControl(HWND hWnd, TModule* module = 0);
  65.  
  66.     // These methods are called for owner-draw controls (buttons, list boxes,
  67.     // and combo boxes)
  68.     //
  69.     virtual int   CompareItem(COMPAREITEMSTRUCT far& compareInfo);
  70.     virtual void  DeleteItem(DELETEITEMSTRUCT far& deleteInfo);
  71.     virtual void  MeasureItem(MEASUREITEMSTRUCT far& measureInfo);
  72.     virtual void  DrawItem(DRAWITEMSTRUCT far& drawInfo);
  73.  
  74.     // Default behavior for DrawItem is to call one of the following based on
  75.     // the draw type:
  76.     //
  77.     virtual void  ODADrawEntire(DRAWITEMSTRUCT far& drawInfo);
  78.     virtual void  ODAFocus(DRAWITEMSTRUCT far& drawInfo);
  79.     virtual void  ODASelect(DRAWITEMSTRUCT far& drawInfo);
  80.  
  81.     // Message response functions
  82.     //
  83.     void          EvPaint();
  84.     TResult       EvCompareItem(uint ctrlId, COMPAREITEMSTRUCT far& comp);
  85.     void          EvDeleteItem(uint ctrlId, DELETEITEMSTRUCT far& del);
  86.     void          EvDrawItem(uint ctrlId, DRAWITEMSTRUCT far& draw);
  87.     void          EvMeasureItem(uint ctrlId, MEASUREITEMSTRUCT far& meas);
  88.  
  89.   protected:
  90.     TNativeUse    NativeUse;  // Using a native control implementation
  91.  
  92.   private:
  93.     // Hidden to prevent accidental copying or assignment
  94.     //
  95.     TControl(const TControl&);
  96.     TControl& operator =(const TControl&);
  97.  
  98.   DECLARE_RESPONSE_TABLE(TControl);
  99.   DECLARE_STREAMABLE(_OWLCLASS, TControl, 2);
  100. };
  101.  
  102. // Generic definitions/compiler options (eg. alignment) following the 
  103. // definition of classes
  104. #include <services/posclass.h>
  105.  
  106. #if defined(BI_NAMESPACE)
  107. } // namespace OWL
  108. #endif
  109.  
  110. //----------------------------------------------------------------------------
  111. // Inline Implementations
  112. //
  113.  
  114. //
  115. // Return if OWL is using the native common control or not.
  116. //
  117. inline TNativeUse TControl::GetNativeUse() const
  118. {
  119.   return NativeUse;
  120. }
  121.  
  122. #endif  // OWL_CONTROL_H
  123.